package mapReduce.demo04_IOFormat.inputFormat;

import mapReduce.util.JobSubmit;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.lib.input.KeyValueTextInputFormat;

import java.io.IOException;

public class KeyValueTextInputFormatApp {

    public static class KVTFIFMapper extends Mapper<Text,Text,Text, IntWritable>{

        IntWritable outValue = new IntWritable();

        @Override
        protected void map(Text key, Text value, Mapper<Text, Text, Text, IntWritable>.Context context) throws IOException, InterruptedException {
            outValue.set(Integer.parseInt(value.toString()));

            context.write(key,outValue);
        }
    }

    public static void main(String[] args) {
        JobSubmit.setSeperator(",");
        JobSubmit.submitBaseJob(KeyValueTextInputFormatApp.class,
                args,
                0,
                KeyValueTextInputFormat.class
        );
    }
}
